package com.lovely602.langchain4j.persistent.controller;


import com.lovely602.langchain4j.persistent.service.PersistentChatAssistant;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author lizhixing
 */
@Slf4j
@RestController
@RequestMapping(value = "/persistent")
public class ChatPersistentController {

    @Resource
    private PersistentChatAssistant persistentChatAssistant;

    /**
     * 持久化聊天内容
     */
    @GetMapping(value = "/chat")
    public String chat(@RequestParam(value = "memoryId", defaultValue = "1") String memoryId, @RequestParam(value = "msg", defaultValue = "你是谁") String msg) {
        return persistentChatAssistant.chat(memoryId, msg);
    }

}
